from _hellchin_webrun.src.core.browser.base import BaseTest
# from _hellchin_webrun.src.core.utils.logger.run_logger import TestLogger
from _hellchin_webrun.src.core.utils.chinese_alias import KeyWordManage
import typing


class MouseKeyboardMixin(BaseTest):
    """键盘鼠标输入相关的操作"""

    @KeyWordManage.chinese_alias("鼠标点击")
    def mouse_click(
            self,
            x,
            y,
            *,
            button: typing.Literal["left", "middle", "right"] | None = None,
            count=1
    ) -> None:
        """模拟鼠标点击"""
        # print(f"正在模拟鼠标点击：({x}, {y})")
        # TestLogger.start.suit_log(f"正在模拟鼠标点击：({x}, {y})")
        self.page.mouse.click(x, y, button=button, click_count=count)
        # TestLogger.success.suit_log(f"模拟鼠标点击：({x}, {y})")

    @KeyWordManage.chinese_alias("鼠标移动")
    def move_mouse(self, x, y):
        """模拟鼠标移动"""
        # print(f"正在模拟鼠标移动：({x}, {y})")
        # TestLogger.start.suit_log(f"正在模拟鼠标移动：({x}, {y})")
        self.page.mouse.move(x, y)
        # TestLogger.success.suit_log(f"模拟鼠标移动：({x}, {y})")

    @KeyWordManage.chinese_alias("键盘按键")
    def press_key(self, key):
        """模拟键盘按键"""
        # print(f"正在模拟键盘按键：{key}")
        # TestLogger.start.suit_log(f"正在模拟键盘按键：{key}")
        self.page.keyboard.press(key)
        # TestLogger.success.suit_log(f"模拟键盘按键：{key}")

    @KeyWordManage.chinese_alias("键盘输入文本", "键盘输入")
    def press_type(self, text):
        """模拟键盘输入文本"""
        # print(f"正在模拟键盘输入：{text}")
        # TestLogger.start.suit_log(f"正在模拟键盘输入：{text}")
        self.page.keyboard.type(text)
        # TestLogger.success.suit_log(f"模拟键盘输入：{text}")
